package com.brand.prisd.activity;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.brand.prisd.R;
import com.brand.prisd.ViewHolder.Type6ViewHolder;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

import static com.brand.prisd.bean.VariableStorage.AllDevicesActivity_RV_ItemCounts;
import static com.brand.prisd.bean.VariableStorage.ITEM_VIEW_TYPE_6;

public class AllDevicesActivity extends AppCompatActivity {

    @BindView(R.id.rv)
    RecyclerView rv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_all_devices);
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        rv.setLayoutManager(new LinearLayoutManager(this));
        rv.setAdapter(new RVAdapter());

    }


    private void go2ChooseDeviceTypeActivity() {
//        startActivity(new Intent(this, ChooseDeviceTypeActivity.class));
        finish();
    }

    @OnClick(R.id.iv_left_arrow)
    public void onViewClicked() {
        go2ChooseDeviceTypeActivity();
    }

    class RVAdapter extends RecyclerView.Adapter {

        @Override
        public int getItemViewType(int position) {
            return ITEM_VIEW_TYPE_6;
        }

        @NonNull
        @Override
        public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
            switch (viewType) {
                case ITEM_VIEW_TYPE_6:
                default:
                    return new Type6ViewHolder(LayoutInflater.from(getApplicationContext()).inflate(R.layout.add_device_type6_item, viewGroup, false));
            }

        }

        @Override
        public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
            Type6ViewHolder type6ViewHolder = (Type6ViewHolder) viewHolder;
            type6ViewHolder.setDataInAllDevicesActivity(position);
        }

        @Override
        public int getItemCount() {
            return AllDevicesActivity_RV_ItemCounts;
        }


    }
}
